{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# QR code Scanner"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Decoded Data : https://www.instagram.com/programming_fever/\n",
      "[[[ 40.  40.]]\n",
      "\n",
      " [[369.  40.]]\n",
      "\n",
      " [[369. 369.]]\n",
      "\n",
      " [[ 40. 369.]]]\n"
     ]
    }
   ],
   "source": [
    "#programming_fever\n",
    "import cv2\n",
    "import numpy as np\n",
    "import sys\n",
    "import time\n",
    "\n",
    "inputImage = cv2.imread(\"D://OpenCV//opencv jupyter files//programming_fever.png\")\n",
    "# Display barcode and QR code location\n",
    "def display(im, bbox):\n",
    "    n = len(bbox)\n",
    "    for j in range(n):\n",
    "        cv2.line(im, tuple(bbox[j][0]), tuple(bbox[ (j+1) % n][0]), (255,0,0), 3)\n",
    "\n",
    "    # Display results\n",
    "    cv2.imshow(\"Results\", im)\n",
    "    \n",
    "qrDecoder = cv2.QRCodeDetector()\n",
    "# Detect and decode the qrcode\n",
    "data,bbox,rectifiedImage = qrDecoder.detectAndDecode(inputImage)\n",
    "if len(data)>0:\n",
    "    print(\"Decoded Data : {}\".format(data))\n",
    "    display(inputImage, bbox)\n",
    "    rectifiedImage = np.uint8(rectifiedImage)\n",
    "    cv2.imshow(\"Rectified QRCode\", rectifiedImage)\n",
    "\n",
    "else:\n",
    "    print(\"QR Code not detected\")\n",
    "    cv2.imshow(\"Results\", inputImage)\n",
    "\n",
    "cv2.waitKey(0)\n",
    "cv2.destroyAllWindows()\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "FB Page\n",
    "<a href=\"https://www.facebook.com/GeekyPRAVEE\">@programmimg_fever</a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "GitHub link\n",
    "<a href=\"https://github.com/GeekyPRAVEE\">@programmimg_fever</a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Twitter \n",
    "<a href=\"https://twitter.com/GeekyPRAVEE\">@programmimg_fever</a>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
